<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li{
            width: 600px;
            height: 20px;
            margin: 20px 0px;
        }
    </style>
</head>
<body>
    <textarea></textarea>
    <button id="one">发布</button>
    <button id="two" >删除</button>
    <ul>

    </ul>
    <script>
        var btn1 = document.querySelector('#one');
        var btn2 = document.querySelector('#two');
        var text = document.querySelector('textarea');
        var ul = document.querySelector('ul');
        
        btn1.onclick = function(){
            var li = document.createElement('li');
            li.innerHTML = text.value + "<button style='float: right;' class='del'>删除</button>";
            ul.insertBefore(li,ul.children[0]);
            btn2.disabled = false;
            var del = document.querySelectorAll('.del');
            for(var i=0;i<del.length;i++){
                del[i].onclick = function(){
                    ul.removeChild(this.parentNode);
                }
            }
        }
        btn2.onclick = function(){
            ul.removeChild(ul.children[0]);
            if(ul.children.length == 0){
                btn2.disabled = true;
            }
        }
    </script>
</body>
</html>